<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>制造商品牌管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function removeVender(id){
			$.ajax({
				url:"${ctx}/sys/vender/isExistMaterielByVenderCode?id="+id,
				success:function(result){
					if(result>0){
						showTip("该制造商品牌存在物料，不能删除!",'',3000,0);
						return false;
					}else{
						var queryName = $('#queryName').val();
						var queryType = $('#queryType').val();
						var pageNo = $('#pageNo').val();
						var pageSize = $('#pageSize').val();
						var condition = "";
						if(queryName!=null && queryName!=''){
							condition = condition + '&queryName='+queryName;
						}
						if(queryType!=null && queryType!=''){
							condition = condition + '&queryType='+queryType;
						}
						if(pageNo!=null && pageNo!=''){
							condition = condition + '&pageNo='+pageNo;
						}
						if(pageSize!=null && pageSize!=''){
							condition = condition + '&pageSize='+pageSize;
						}
						confirmx('确认要删除该制造商品牌吗？','${ctx}/sys/vender/delete?id='+id+condition);
					}
				}
			});
		}
		function resetFunc(){
			$("#searchForm input[type='text']").val("");
			$('#s2id_queryType').find('.select2-chosen').html('所有');
			$("#queryType").find("option")[0].selected='selected';
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/vender/">制造商品牌列表</a></li>
		<li><a href="${ctx}/sys/vender/venderAdd?id=${vender.id}">制造商品牌<shiro:hasPermission name="sys:vender:edit">${not empty vender.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sys:vender:edit">查看</shiro:lacksPermission></a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="vender" action="${ctx}/sys/vender/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>品牌名称：</label>
				<form:input path="queryName" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>品牌分类：</label>
				<form:select path="queryType" class="input-medium">
			    <form:option value="" label="所有"/>
			    <form:options items="${fns:getDictList('vender_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/></li>
			<li class="btns"><input class="btn btn-primary" type="button" value="重置" onclick="resetFunc()"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<div style="display:none;">
		<sys:message content="${message}"/>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>品牌分类</th>
				<th>品牌名称</th>
				<th>是否极配自主品牌</th>
				<th>品牌描述</th>
				<shiro:hasPermission name="sys:vender:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="vender" varStatus="index"> 
			<tr>
				<td>${index.index+1 }</td>
				<td>${fns:getDictLabel(vender.type, 'vender_type', '')}</td>
				<td>${vender.name}</td>
				<c:if test="${vender.type==1}">
					<td>--</td>
				</c:if>
				<c:if test="${vender.type==2}">
					<td>${fns:getDictLabel(vender.isMyself, 'yes_no', '')}</td>
				</c:if>
				<td>${vender.remarks}</td>
				<shiro:hasPermission name="sys:vender:edit"><td>
    				<a href="${ctx}/sys/vender/venderEdit?id=${vender.id}">修改</a>
					<a href="javascript:;" onclick="removeVender(${vender.id})">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>